/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.derby.drda.NetworkServerControl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author leadiv
 */
public class testing {

    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Connection conn;
                

                
                try {
                    String nsURL="jdbc:derby://localhost:1226/deliciousBlogger";
                    java.util.Properties props = new java.util.Properties();
                    props.setProperty("user","dbuser");
                    props.setProperty("password","f6i53t");

                    /*
                        If you are running on JDK 6 or higher, you do not
                        need to invoke Class.forName(). In that environment, the
                        ClientDriver loads automatically.
                    */
                    Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
//                    Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
                    conn = DriverManager.getConnection(nsURL, props);

                    Statement s = conn.createStatement();
                    ResultSet rs = s.executeQuery("select USERNAME from \"Model\".USERS");

                    while (rs.next()) {
                        System.out.println("Name: " + rs.getString(1));
                    }

                    rs.close();
                    s.close();
                    conn.close();


                    NetworkServerControl serverControl = new NetworkServerControl();
                    System.out.println(serverControl.getSysinfo());
                    serverControl.shutdown();
            
                } catch(Exception ex) {
                    Logger.getLogger(ProfileSQL.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
}